﻿using System;
using System.Collections.Generic;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Exceptions;

namespace SchEdu.Framework.Validators
{

    public class WorkCenterValidator : Validator
    {
        int maxWorkCenter = -1;
        public int MaxWorkCenter
        {
            get { return maxWorkCenter; }
            set { maxWorkCenter = value; }
        }

        int minWorkCenter = -1;
        public int MinWorkCenter
        {
            get { return minWorkCenter; }
            set { minWorkCenter = value; }
        }

        public WorkCenterValidator(SchEduData schEduData, int minWorkCenter, int maxWorkCenter)
            : base(schEduData)
        {
            this.minWorkCenter = minWorkCenter;
            this.maxWorkCenter = maxWorkCenter;
        }

        #region IValidator Members

        public override void Validate()
        {
            if (minWorkCenter != -1 && SchEduData.WorkCenter.Count < minWorkCenter)
            {
                throw new ValidatorException(string.Format(Resources.MinWorkCenter, minWorkCenter));
            }
            if (maxWorkCenter != -1 && SchEduData.WorkCenter.Count > maxWorkCenter)
            {
                throw new ValidatorException(string.Format(Resources.MaxWorkCenter, minWorkCenter));
            }

        }

        #endregion
    }
}
